Title: Infinite Bazooka Ammo fix
Author: Squa.. Assassin.  That's right; it was all me. ;)
Version: Beta 0.20
Applies to: Secret of Evermore -- US version (Don't confuse this with the English
            European version, which is PAL rather than NTSC.  Also, I can only
            attest to the bug being on ROM version 1.0, though I'm told that's the
            only US release anyway.)
Tested on: US version

Contents:

        InfAmmo.ips = the SoE (US) patch
  
        NInfAmmo.ips = the SoE (US) anti-patch

        The "Anti-patch" effectively removes this patch.

        readme.txt = this file

        ammo-decrement-orig.txt = commented original code (US)
        ammo-decrement-fix.txt  = commented fixed code (US)
        ammo-decrement-orig-europe.txt = commented fixed original code (Europe).
                                         the fix was all Square's work; this file
                                         is here for reference.

ROM Addresses: SoE US - 1084E4, 1084E9, 1084ED thru 1084F7, 1084FD thru 108558

Functions added: None
Additional Square functions used: None

Urgency: Medium high.  Hell, the bug gives you infinite Particle Bombs and Cryo-Blasts.
         It doesn't come into play until Omnitopia, where money is easily amassed and the
         dog is quite strong.  Nonetheless, it's uber cheap.  Even John Rambo, who took out
         an entire enemy base unassisted, would be insulted by the logical fallacy of
         flattening all of Omnitopia with a single bazooka shell.
         ("Yo.. that ain't right.")

============================================================================================

The latest versions of all my patches can be found at either of these sites:

http://www14.brinkster.com/assassin17/
http://assassin17.home.comcast.net/

============================================================================================

TABLE OF CONTENTS

0. Description
1. Cause and Further Explanation
2. What my Patch Does
3. What Else this Patch Arguably Fixes
4. For Testers
5. FAQ
6. Revision History
7. Credits
Unnumbered: Copyright notice

____________________________________________________________________________________________

0. DESCRIPTION
____________________________________________________________________________________________

When you fire Particle Bombs or Cryo-Blasts from the Bazooka, the ammunition is never
actually consumed.  Hence an infinite supply.  That shouldn't happen.  Thunder Ball works
fine.

The cause is that a routine which sets up attacks will only check and decrement the
ammunition count if the attack type is Thunder Ball.

The European versions of SoE fixed things by expanding that test to also include Particle
Bomb and Cryo-Blast.  I followed Square's example for this USA patch.

____________________________________________________________________________________________

1. CAUSE AND FURTHER EXPLANATION
____________________________________________________________________________________________

Section 0 pretty much covers it.  Why is it that the most important bugs are often the
simplest to explain?

I guess I'll elaborate on the role of the deficient function, for those who are curious
and can't read assembly.  Entities in this game (characters or monsters) have different
types of physical attacks that will be used depending on how charged their meter is.
The meters for the boy and dog are obvious; you see the actual gauges.  I'm not quite sure
how it works for monsters, but there is some sort of time-based charging mechanism.

One can assign a unique attack to each of four levels of charging, and this routine picks
which attack is performed.  Note that Attack power is also modified based on the meter,
but in a different routine, and there's one more level to consider.  I'll put it all into
one handy table.


Meter value (M)     |  In other words          |  Attack used   |  Change to Attack power
------------------------------------------------------------------------------------------
M < 0200h              M < 50%                    Attack type 1    Quartered
0200h <= M < 0400h     50% <= M < 100%            Attack type 1    Halved
0400h <= M < 0800h     100% <= M < Level 2        Attack type 2    No change
0800h <= M < 0C00h     Level 2 <= M < Level 3     Attack type 3    Doubled
M = 0C00h              M = Level 3                Attack type 4    Quadrupled

In case you've forgotten, Level 2 is a full thin red bar, and Level 3 a full thick red bar.


For monsters, the four possible attack types are in ROM.  For characters, they're in RAM,
because the possible attacks can vary depending on which weapon you have equipped (and on
the ammo, if that weapon is the Bazooka) or on the form of the dog.  Characters will
generally use a different attack at each of the four levels.  Exceptions are the first
three dogs, whose attacks are uniform aside from damage.  Another is the Bazooka, which can
only be charged to 100%.  Thus, it just has the Bazooka bludgeon attack (which is the same
value regardless of ammo type -- 3EEEh in the US version) in the first slot, and firing of
the current ammo (41CAh for Thunder Ball in the US version, 41DAh for Particle Bomb, or
41EAh for Cryo-Blast) in the other three slots.

One difference between the ammo types (aside from Battle Power, which was determined well
before calling this function) is that the more powerful the shell, the further the Bazooka's
kick throws the boy backward.

If an attack is performed and its type is 41CA (Thunder Ball firing), the game will check
the quantity of your currently loaded ammo.  If it's zero, it swaps in Bazooka Bludgeon for
the attack; otherwise, it decrements the ammo count and proceeds with the shot.

Because it only does this for Thunder Ball, Particle Bomb and Cryo-Blast will never be
expended.

I'm sure this was just an oversight by Square, since they account for all three ammo types
in the game's European versions, which were released sometime after the USA one.

____________________________________________________________________________________________

2. WHAT MY PATCH DOES
____________________________________________________________________________________________

It does what Square does in the European versions: checks and decrements the current ammo
count if the attack involves firing of ANY of the three Bazooka shells.

I had to optimize a little to fit the added code in the existing space, and the attack
types have different index values in the European releases than they do in the US.
Aside from that, my new function is just a replica of Square's, so thank them for the
solution. :)

____________________________________________________________________________________________

3. WHAT ELSE THIS PATCH ARGUABLY FIXES
____________________________________________________________________________________________

As mentioned in Section 1:

"If an attack is performed and its type is 41CA (Thunder Ball firing), the game will check
the quantity of your currently loaded ammo.  If it's zero, it swaps in Bazooka Bludgeon for
the attack; otherwise, it decrements the ammo count and proceeds with the shot."

On top of ammo decrementation being limited to Thunder Ball, so is replacing an attempted
empty firing with the bludgeoning.  This means that if you were to select Particle Bomb or
Cryo-Blast then attempt a shot after somehow depleting your entire supply, the game would
fail to switch to the bludgeon, and instead follow through with the shot.  This would be an extension of the infinite ammo bug (only you're getting a shell from nowhere as opposed to
having a magically regenerating shell).  However, you can't sell ammo (right?), and the
same bug prevents you from using up those types of ammunition.  Hence the theoretical
problem being banished to its own Readme section. :)

____________________________________________________________________________________________

4. FOR TESTERS
____________________________________________________________________________________________

Any testing is appreciated.  This patch is fairly simple, but it's always possible I
overlooked something.

Please provide feedback on the GameFAQs Secret of Evermore message board:  
http://www.gamefaqs.com/console/snes/data/588645.html

or Mnrogar's Den:
http://www.mnrogar.com/

Thanks!

____________________________________________________________________________________________

5. FAQ
____________________________________________________________________________________________

Q: When you're out of ammo, why does the last ammunition you had loaded still appear in the
   STAT menu, and its Battle Power still appear when you're in the Weapon Ring?

A: I hear ya!  Frankly, I would have added a fourth ammunition type of "None" and given it
   its own data block.  Not doing this may've been another oversight on Square's part.
   More likely, they knew they just could get away with a check to change the attack
   performed by an empty Bazooka (as described in Section 1 and shown in the commented
   assembly files).  Thus, while showing ammo you don't have may be illogical, it won't have
   any meaningful impact on gameplay.

   At any rate, addressing the issue is currently beyond my ability.  I'd have to change a
   lot more code, introduce a new data block for the empty Bazooka, and create a new icon
   for it.  That would be challenging under any circumstance, but because I don't know where
   this game's free space blocks are, I really have no shot at it (no pun intended).

____________________________________________________________________________________________

6. REVISION HISTORY
____________________________________________________________________________________________

Version 0.20 : May 10 through May 17 2005

  - May 1: After reading a GameFAQs topic on the matter, I decided I'd finally fix the dang
    thing.  Didn't do any work right away because I was busy finishing a different patch.
  - May 10 onward: Pinned down the cause, started on the commented assembly files, made
    the patch, tested it, wrote this Readme, finished the commented assembly files, made
    the anti-patch.  Tested the patch a little more.
  - May 17: Released patch.

____________________________________________________________________________________________

7. CREDITS
____________________________________________________________________________________________

  - Squaresoft for making this game and for fixing the bug in the European versions.  That
    not only saved me the tedium of making umpteen separate patches, but it made the USA
    patch quite a stroll in the park. :)

  - androl for the old GameFAQs Bugs and Glitches topic, which is probably where I first
    learned about the Infinite Ammo bug.

  - Dark RPG Wizard 06 of the GameFAQs Secret of Evermore board for a decent theory about
    the bug's cause.

  - AltomareLatios for starting a recent GameFAQs topic, which prompted me to turn my
    attention to this long-known bug.

______________________________________________________________________________________________

Secret of Evermore copyright 1995 Squaresoft.
This readme and all other files in the archive (as listed above)
  copyright 2005 Assassin.
All rights reserved.

